/**
 * 用户管理js
 */

$(function () {
	initialPage();
	getGrid();
});

function initialPage() {
	$(window).resize(function() {
		$('#dataGrid').bootstrapTable('resetView', {height: $(window).height()-54});
	});
}

function getGrid() {
	
	$('#dataGrid').bootstrapTableEx({
		url: '../../goods/giftlist/list?_' + $.now(),
		height: $(window).height()-54,
		queryParams: function(params){
			params.contactName = vm.keyword;
			params.contactPhone = vm.keyword;
			params.contactAddress = vm.keyword;
			params.startDate= vm.startDate;
			params.endDate= vm.endDate;
			params.expressStatusId = vm.expressStatusId;
			return params;
		},
		columns: [{
			checkbox: true
		}, {
			field : "contactName",
			title : "联系人",
			width : "10px"
		},   {
			field : "contactPhone",
			title : "联系电话",
			width : "10px"
		}, {
			field : "contactAddress",
			title : "联系地址",
			width : "150px",
			 
		}, {
			field : "updateDate",
			title : "时间",
			width : "30px",
			 
		}, {
			field : "expressStatus",
			title : "是否发货",
			width : "30px",
			 formatter : function(value , row, index) {
	             if(value==null){
	                 return '未发货';
	             }else
	             {
	                 return value;
	             }
	         }
			 
		} 
		, {
			field : "expressNum",
			title : "快递单号",
			width : "30px",
			 
		} , {
			field : "channel",
			title : "来源",
			width : "30px",
			 
		} 
		]
	})
}

var vm = new Vue({
	el:'#dpLTE',
	data: {
		keyword: null,
		startDate:null,
		endDate:null,
		expressStatusId:null
	},
	methods : {
		load: function() {
			
			vm.startDate=$("#startDate").val();
			vm.endDate=$("#endDate").val();
			$('#dataGrid').bootstrapTable('refresh');
		},
		
		save: function() {
			dialogOpen({
				title: '新增展区',
				url: 'base/exhibitionhall/add.html?_' + $.now(),
				width: '600px',
				height: '350px',
				scroll : true,
				yes : function(iframeId) {
					top.frames[iframeId].vm.acceptClick();
				},
			});
		},
		edit: function() {
			var ck = $('#dataGrid').bootstrapTable('getSelections');
			if(checkedRow(ck)){
				dialogOpen({
					title: '物流编辑',
					url: 'base/goods/expressedit.html?_' + $.now(),
					width: '600px',
					height: '350px',
					scroll : true,
					success: function(iframeId){
						top.frames[iframeId].vm.goodsOrderContact.recId = ck[0].recId;
						top.frames[iframeId].vm.setForm();
					},
					yes : function(iframeId) {
						top.frames[iframeId].vm.acceptClick();
					},
				});
			}
		},
		remove: function() {
			var ck = $('#dataGrid').bootstrapTable('getSelections'), ids = [];	
			if(checkedArray(ck)){
				$.each(ck, function(idx, item){
					ids[idx] = item.exhibitionHallId;
				});
				$.RemoveForm({
					url: '../../servicedata/exhibitionhall/remove?_' + $.now(),
			    	param: ids,
			    	success: function(data) {
			    		vm.load();
			    	}
				});
			}
		}
	}
})